package slef.xchen;

import java.util.concurrent.CountDownLatch;

/**
 * @author chenxing
 */
public class Demo {
	public static void main(String[] args) throws InterruptedException {
		CountDownLatch countDownLatch = new CountDownLatch(100);
		//初始化delay executor, 在项目启动后执行一次
		Turntable<String> turntable = new Turntable<>("test", 10, dataList -> {
			for (int i = 0; i < dataList.size(); i++) {
				countDownLatch.countDown();
			}
			String result = String.join(",", dataList);
			System.out.println(result);
		});
		DelayHelper.register(turntable);

		//使用此delay executor
		for (int i = 0; i < 100; i++) {
			DelayHelper.use("test").add("test" + i);
			Thread.sleep(200);
		}
		countDownLatch.await();
		DelayHelper.shutdown();
	}


}
